package com.jsfcomponent.domain;

import java.io.Serializable;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;

@Entity
public class Honey implements Serializable {
	@Id
	private int id;

	private String name;

	private String taste;

	@OneToMany(mappedBy="honey", fetch=FetchType.LAZY)
	private Set<Bee> beeCollection;

	private static final long serialVersionUID = 1L;

	public Honey() {
		super();
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTaste() {
		return this.taste;
	}

	public void setTaste(String taste) {
		this.taste = taste;
	}

	public Set<Bee> getBeeCollection() {
		return this.beeCollection;
	}

	public void setBeeCollection(Set<Bee> beeCollection) {
		this.beeCollection = beeCollection;
	}
	
	
	@Override
	public boolean equals(Object obj) {
		if(!(obj instanceof Honey)){
			return false;
		}
		Honey other=(Honey) obj;
		return id==other.getId() && other.getName().equals(getName());
	}
	
	@Override
	public int hashCode() {	
		return id+((name!=null)?name.hashCode():super.hashCode());
	}
}
